package com.bianguo.android.apushdemo.view.wiget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewGroup;

import com.bianguo.android.apushdemo.utils.MyLog;

/**
 * Created by Administrator on 2017/8/24.
 */

public class CustomViewGroup extends ViewGroup {


    public CustomViewGroup(Context context) {
        super(context);
        initView(context, null);
    }

    public CustomViewGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context, attrs);
    }

    public CustomViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context, attrs);
    }

    private void initView(Context mContext, AttributeSet attrs) {

    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                MyLog.mLog("onTouchEvent Down");
                return true;
            case MotionEvent.ACTION_MOVE:
                MyLog.mLog("onTouchEvent Move");
                return true;
            case MotionEvent.ACTION_UP:
                MyLog.mLog("onTouchEvent UP");
                break;
            case MotionEvent.ACTION_CANCEL:
                MyLog.mLog("onTouchEvent Cancel");
                return true;
        }
        return super.onTouchEvent(event);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                MyLog.mLog("dispatchTouchEvent Down");
                return true;
            case MotionEvent.ACTION_MOVE:
                MyLog.mLog("dispatchTouchEvent Move");
                return true;
            case MotionEvent.ACTION_UP:
                MyLog.mLog("dispatchTouchEvent UP");
                break;
            case MotionEvent.ACTION_CANCEL:
                MyLog.mLog("dispatchTouchEvent Cancel");
                return true;
        }
        return super.dispatchTouchEvent(ev);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {

    }
}
